<?php
namespace frontend\controllers;

use Yii;
use yii\web\Controller;
use vendor\animal\Cat;
use vendor\animal\Mouse;
use vendor\animal\Dog;
use \yii\base\Event;

/**
 * Hello controller
 */
class AnimalController extends Controller
{
    public function actionIndex()
    {
//         $cat  = new Cat();
//         $cat2  = new Cat();
//         $mouse = new Mouse();
//         $dog = new Dog();
        
//         Event::on(Cat::className(),'miao',[$mouse,'run']);
        
//         Event::on(Cat::className(),'miao',function(){
//             echo 'cat is shout !!!<br/>';
//         });
            
//         \Yii::$app->on(\yii\base\Application::EVENT_AFTER_REQUEST,function(){
            
//             echo "event after run<br/>";
//         });
        
//         echo "hhhhhh<br/>";
        
//         $cat->on('miao',[$mouse,'run']);
//         $cat->on('miao',[$dog,'look']);
        
//         $cat->off('miao',[$dog,'look']);
        
//         $cat->shout();
//         $cat2->shout();

        $dog = new Dog();
        $dog->look();
        $dog->eat();
        
        
    }
}
